/* D:\ICADDEV\PRJ\ICAD\PREFERENCES.H
 * Copyright (C) 1997-1999 DIMINE Co.LTD. All rights reserved.
 * 
 * $Revision: 1.1.1.1 $ $Date: 2010/03/03 02:57:12 $ 
 * 
 * Abstract
 * 
 * Common utilities for managing user preferences.
 * 
 */ 

#ifndef	_PREFERENCES_H
#define	_PREFERENCES_H

/*	PreferenceKey is just a simple way to open a static named key
 *	All PreferenceKeys are subkeys of the application root.
 */

class PreferenceKey : public CRegKey
	{
public:
	PreferenceKey( HKEY tree, const CString& subkey, bool create = TRUE);
	LONG FlushKey(HKEY tree, const CString& keyname);

private:
	 static char m_applicationRoot[MAX_PATH];
//	static  BOOL m_bStart;
//	static	CString m_applicationRoot;
 
	};


/*	Registry preference classes support loading and saving of preference values
 *	to the registry upon application initialization and exit.
 *
 *	Each preference value has a name and exists within a parent key in the registry.
 *	The value is saved if it is different from the default value, otherwise the value
 *	is deleted from the registry.
 *
 */

	// base class for various value types
class RegistryPreference : public CRegKey
	{
public:
	RegistryPreference( CRegKey& key) : m_key( key) {}
protected:
	CRegKey&	m_key;
	};

	// Boolean preference value
class BooleanPreference : public RegistryPreference
	{
public:
	BooleanPreference( CRegKey& parent, const CString name, bool defaultValue = false);
	~BooleanPreference();

	bool operator =( bool value)	{ return m_value = value; }
	operator bool()					{ return m_value; }

private:
	CString	m_name;
	bool	m_default;
	bool	m_value;
	};


	// Integer preference value
class IntPreference : public RegistryPreference
	{
public:
	IntPreference( CRegKey& parent, const CString name, int defaultValue = 0);
	~IntPreference();

	int operator =( int value)		{ return m_value = value; }
	operator int()					{ return m_value; }

private:
	CString	m_name;
	int		m_default;
	int		m_value;
	};


class UserPreference
{
public:
	static BooleanPreference	crosshairPreference;
	static IntPreference		crosshairSizePreference;

	static BooleanPreference	GripsAttractionPreference;
	static IntPreference		GripsAttractionDistancePreference;

	static BooleanPreference	ContinuousMotionPreference;

	// DP: Now we save and load this variable together with others.
	//static IntPreference		OSModePreference;

	static BooleanPreference	SnapMarkerPreference;
	static IntPreference		SnapMarkerSizePreference;
	static IntPreference		SnapMarkerThicknessPreference;
	static IntPreference		SnapMarkerColorPreference;
	static BooleanPreference	SnapMarkerDrawInAllViews;
	static BooleanPreference	SnapTooltipsPreference;
	static BooleanPreference	SnapApertureBoxPreference;

};


#endif


